Warning: mkdir(): No space left on device in /var/www/tg-me/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/proglib_academy/--): Failed to open stream: No such file or directory in /var/www/tg-me/post.php on line 50
Proglib.academy | IT-курсы | Telegram Webview: proglib_academy/2751 -
Telegram Group & Telegram Channel
🌐 Быстрая проверка простоты числа в Python

Хотите понять, простое число или нет. Есть два способа: быстрый и ещё быстрее.

Число считается простым, если делится только на 1 и само себя.

1️⃣ Способ: классический перебор — Подходит для небольших чисел — Легкий для понимания

def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True


Проверяем деление до √n — быстрее, чем до самого n!

2️⃣ Способ: через списковые выражения (one-liner) — Красиво — Для любителей компактного кода

is_prime = lambda n: n > 1 and all(n % i for i in range(2, int(n**0.5)+1))


Функция в одну строку. Но читаемость иногда важнее красоты

🔵 Включайся в обучение и устраивайся куда хочешь, тебя ждет продвинутый этап нашего курса «Алгоритмы и структуры данных»

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2751
Create:
Last Update:

🌐 Быстрая проверка простоты числа в Python

Хотите понять, простое число или нет. Есть два способа: быстрый и ещё быстрее.

Число считается простым, если делится только на 1 и само себя.

1️⃣ Способ: классический перебор — Подходит для небольших чисел — Легкий для понимания

def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True


Проверяем деление до √n — быстрее, чем до самого n!

2️⃣ Способ: через списковые выражения (one-liner) — Красиво — Для любителей компактного кода

is_prime = lambda n: n > 1 and all(n % i for i in range(2, int(n**0.5)+1))


Функция в одну строку. Но читаемость иногда важнее красоты

🔵 Включайся в обучение и устраивайся куда хочешь, тебя ждет продвинутый этап нашего курса «Алгоритмы и структуры данных»

Proglib Academy #буст

BY Proglib.academy | IT-курсы




Share with your friend now:
tg-me.com/proglib_academy/2751

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

The global forecast for the Asian markets is murky following recent volatility, with crude oil prices providing support in what has been an otherwise tough month. The European markets were down and the U.S. bourses were mixed and flat and the Asian markets figure to split the difference.The TSE finished modestly lower on Friday following losses from the financial shares and property stocks.For the day, the index sank 15.09 points or 0.49 percent to finish at 3,061.35 after trading between 3,057.84 and 3,089.78. Volume was 1.39 billion shares worth 1.30 billion Singapore dollars. There were 285 decliners and 184 gainers.

Launched in 2013, Telegram allows users to broadcast messages to a following via “channels”, or create public and private groups that are simple for others to access. Users can also send and receive large data files, including text and zip files, directly via the app.The platform said it has more than 500m active users, and topped 1bn downloads in August, according to data from SensorTower.Proglib academy | IT курсы from cn


Telegram Proglib.academy | IT-курсы
FROM USA